File musical chairs#391
File musical chairs#391dwalton76 merged 18 commits intoev3dev:developfrom dwalton76:file-musical-chairs
Conversation
Here is what we have robot@evb[ev3dev-lang-python]# tree ev3dev/ ev3dev/ ├── button.py ├── control │ ├── GyroBalancer.py │ ├── __init__.py │ └── rc_tank.py ├── display.py ├── fonts // // chopped most of fonts to limit the output here // │ ├── timR18.pbm │ ├── timR18.pil │ ├── timR24.pbm │ └── timR24.pil ├── helper.py ├── __init__.py ├── led.py ├── motor.py ├── _platform │ ├── brickpi.py │ ├── ev3.py │ ├── evb.py │ ├── __init__.py │ └── pistorms.py ├── port.py ├── sensor │ ├── __init__.py │ └── lego.py ├── sound.py ├── version.py └── webserver.py 4 directories, 421 files robot@evb[ev3dev-lang-python]#
|
Ignoring the fonts directory, this is the current structure |
|
Can we make travis have a |
|
Why are there two files for buttons? |
|
version could be put in the root |
|
fonts probably shouldn't be in the source code tree. |
|
Is there anything left in |
|
It seems like it would be cleaner to do some import magic in |
|
|
yeah button and led need some work that was just what I came up with to get the importing working. These are both things where a platform specific class must live in
|
|
@ddemidov thoughts on |
|
Why would we have platform-specific button classes? As far as I can tell, the only thing that should be different is the path to the device node. |
|
There is no guarantee that all platforms will have the same buttons...it just happens that EV3 and EVB do. And since pistorms doesn't have any it shouldn't really have a Button class. |
|
Wait I think pistorms has a |
|
How will documentation work if the same class is not the same between platforms? It seems to me like it would be better to make them all the same and throw a P.S. PiStorms has a Go button. (And one can add buttons to BrickPi using extra gpios) |
|
I'll give you it would certainly clean up the importing. What about LEDs though they differ a good deal from EV3 vs pistorms? |
|
Out of interest, what does |
I don't see why we could not leave them to be as is, except they are only usable with python3/PIL. |
We could put a |
|
See #225 for some background on fonts. |
Do you mean we should put them into a separate package? |
|
Re platform specific buttons: platform file could provide both path for the event file and the list of supported buttons. Since python is a dynamic language, we could use that list (during import) to create properties corresponding to the buttons inside |
BeforeAfter |
|
Latest commit removes |
yes |
cool, @ddemidov can you add that? I haven't done much with ev3dev-lang-fake-sys |
|
What should be in there? Should |
|
Works for me |
|
Should we move 'PowerSupply' out of 'init.py' and into a 'power.py'? |
I'd say "yes", because it's pretty rare that someone would use the power supply class. In my mind it's just clutter for most use cases. (In fact, I think we should try to minimize the classes in init.py overall) |
How so? PiStorms just has one extra color. I wouldn't call that a big difference. |
I'm not sure what is the usual way for distributing data files with python packages, but is just seems odd to have data files mixed in with source code files in the source repository. Maybe better to save this discussion for later though. |
| INPUT_3 = 'in3' | ||
| INPUT_4 = 'in4' | ||
|
|
||
| buttons_filename = '/dev/input/by-path/platform-gpio_keys-event' |
|
I was thinking EV3 had more LEDs than pistorms but now that I look at http://www.ev3dev.org/docs/platform-comparison/ I see that it doesn't. I'll clean up LEDs to follow the same model as buttons. |
|
|
||
| import array | ||
| import time | ||
| import evdev |
There was a problem hiding this comment.
evdev is probably a linux-specific module like fcntl
There was a problem hiding this comment.
I was meaning to ask about the try/except around fcntl...do we have folks running api_test.py on windows?
There was a problem hiding this comment.
Probably not, but any editor with code completion will load the modules.
(Warning, getting a bit off topic here) 👍 for taking advantage of dynamic nature of python to adapt to platforms, but I think I would rather see a single function that works for all buttons rather than identical functions/properties for each button. For example, I have a USB keypad that I can use for BrickPi/PiStorms that has the essential 6 EV3 buttons plus a bunch more. If I wanted to take advantage of other buttons, say the 10 numeric digits, then I would have to write 10 functions, one to handle each button. Whereas, if the button key code is just passed as a parameter, then I just have to write one function with a bunch of |
|
Working on LEDs now... |
|
LEDs are cleaned up, I tested them on EV3 and tried testing on pistorms but ran into ev3dev/ev3dev#978 I think this is far enough along to merge and then we can tackle anything else via separate issues. Will merge tomorrow unless folks want me to hold off. |
|
Also resolves #379 |
|
For issue #375
@dlech @ddemidov @WasabiFan @ensonic take a look, this is a first stab at getting everything split up and moved around. TouchSensor, Motors, ColorSensor, Buttons, InfraredSensor, and LEDs are all working.